<div class="full_w">
    <div class="h_title"><?php echo Yii::t('AdmincpModule.admincp', 'Upload Media'); ?></div>
    <?php 
    foreach(Yii::app()->admin->getFlashes() as $key => $message){
        echo '<div class="n_'.$key.'"><p>'.$message."</p></div>\n";
    }
    ?>
    <form action="/admincp/media/upload" method="post" enctype="multipart/form-data">
    	<div class="element">
            <label>Method: </label>
            <input type="radio" name="method" value="0" <?php if(isset($method) && $method == 0): ?>checked="checked"<?php endif; ?> /> Basic &nbsp;&nbsp; 
            <input type="radio" name="method" value="1" <?php if(isset($method) && $method == 1): ?>checked="checked"<?php endif; ?> /> Flash
		</div>
		<div class="element" id="method1">
        	<label for="files_upload">Select files: </label>
            <input type="file" name="media" id="uploadify" />
        </div>
        <div class="element" id="method0">
        	<label for="files_upload">Select files: </label>
            <div id="uploader">
            	<div><input type="file" name="media[]" size="30" /> <a id="add_more" href="javascript:void(0);" onclick="addMore();">[Add more]</a></div>
            </div>
        </div>
        <div class="entry">
            <input type="hidden" name="id" id="id" value="<?php echo isset($arrItemInfo['post_id'])?$arrItemInfo['post_id']:null; ?>">
            <button type="submit">Submit</button> <button>Reset</button>
        </div>
    </form>
</div>
<script type="text/javascript" src="../libs/jquery/uploadify/jquery.uploadify.min.js"></script>
<link type="text/css" href="../libs/jquery/uploadify/uploadify.css" />
<script type="text/javascript">
$('input[name="method"]').change(function(){
	var id = 'method' + $(this).val();
	showTab(id);
});	
function showTab(tabid){
	$('div[id^=method]').hide();
	$('#'+tabid).show();
}
function addMore(){
	$('#uploader').append('<div><input type="file" name="media[]" size="30" /></div>');
	if($('input[name="media[]"]').length == 5){
		$('#add_more').remove();
	}
}
$(function() {
	showTab('method'+$('input[name="method"]:checked').val());
	$('#uploadify').uploadify({
		'method'   		: 'POST',
		'formData'      : {'<{$SESSION_NAME}>' : '<{$SESSION_ID}>', 'redirect' : '0'},
		'fileObjName' 	: 'media',
		'swf'      		: '<{$smarty.const.LIBRARIES_URL}>/jquery/uploadify/uploadify.swf',
		'uploader' 		: '<{$baseUrl}>/uploading', 
		'height'        : 30,
		'width'         : 120,
		'onQueueComplete' : function(queueData) {
			alert(queueData.uploadsSuccessful + ' files were successfully uploaded.');						
			window.location = "<{$baseUrl}>/";
		} 
	});
});			
</script>